student_scores = {
    "张三":[90,50,49,100],
    "李四":[80,70,100,80],
    "王二麻子":[50,55,44,61]
}
new_stu_scores = sorted(student_scores.items(),key = lambda item:item[1][0] + item[1][1] + item[1][2] + item[1][3],reverse=True)
new_stu_scores = dict(new_stu_scores) # 将元组类型转换为字典
# 保存至 csv 文件
import csv 
with open('D://new_stu_scores.csv', 'w') as csvfile:
    head = ['学生姓名/科目','语文','数学',"英语","历史"]
    writer = csv.writer(csvfile)
    writer.writerow(head) #写首行数据
    keys = list(new_stu_scores.keys()) # 获取所有 key 并转换成列表 
    values = list(new_stu_scores.values()) # 获取所有 value 并转换成列表
    for line in range(len(keys)):
        row = []   # 将学生姓名和成绩组合成一个列表
        row.append(keys[line])
        row.extend(values[line])
        writer.writerow(row)  # 写一行数据
